It was never shown in the comics, upon which the series was based.
The words were written there presumably before the hospital was abandoned, possibly after a large number of patients had been moved into that one area (to better concentrate care) and one or more passed, raising as walkers, and began turning the others.
The person who wrote it was warning others that there were no more living patients past that point.
They presumably left the hospital when it was abandoned by the living (or were killed there, when it was overrun by the dead).
Edit: As pointed out in Blake's answer, written May 28, 2013 (please, upvote that answer), the video game
The Walking Dead
: Survival Instinct features two characters who write this on the doors of the hospital.
Your character can watch as Merle spray-paints it there.
Your character (Daryl) and Merle are important characters on the show, but do not feature in the comics (at least not prominently).
This leads to a question surrounding the canonicity (which, if it isn't a real word, should be ) of the games.
My personal (unsourced) expectation is that the games, show, and comics each have their own unique canon.
The comics and show are dramatically different, so they certainly have distinct canon.
The games, though, may be canon (possibly of a 'lower level', a la Star Wars) with either the TV show or the comics.
My guess is that they would be tied to the show if anything at all - the appearances of the few crossover characters seem to match the show better than the comics.
According to Wikipedia, Survival Instinct is tied closely to the show, while TellTale Games
The Walking Dead is tied to the comics.
Whether these are actual canon for their respective tie-ins, however, is unclear.
scifi.stackexchange.com/users/656/Jeff
In the video game Survival Instinct where you play as Daryl Dixon you see Merle spray paint it and then lock the door up.
It is the same hospital where Rick was in a coma.
In the webisode
The Oath , you can see that it is actually sprayed by Paul.
This is based on October 2013.
scifi.stackexchange.com/users/14884/Blake
The answer is; I did, along with Robbie Martin, the on-set Scenic.
This is a production photo of the turn around shot, the second set of doors I did for the hospital set.
Notice
the font is different?
This version came from the Comic, that we used mostly as story boards.
At the last moment, someone decided that, whoever it was that painted it?
Wouldn't have taken the time to find a brush, so the spray-painted version was done to camera.
It was a bit of a running joke on set "Who painted those doors?" to which they would reply "Johnny, or Robbie, depending on which one of us was around".
Robby's version, fatter to cover mine.
You know when we did this, all we were thinking about was how awful this old gacky hospital was.
And if we would get a disease for just being there!
Who knew that that the show would turn into anything...
Looking back, it was really pretty work, given the time frame we had to produce it in, this is nice!
scifi.stackexchange.com/users/53796/Johnny Land
This can be seen in
The Walking Dead Webisodes: The Oath .
The character Paul sprays "Don't Open, Dead inside" on the doors to the kitchen.
He sprayed this after recovering from near death and escaping walkers (or decays lol), to find his friend Katrina dead, killed by lethal injection from a nurse.
The real crazy thing is that this would make that before Rick wakes up, possibly making Rick there still in a coma while all this took place.
scifi.stackexchange.com/users/17751/Brandon
The military could have been keeping them in there prior to shooting them.
There are bodies lined up outside the hospital and evidence that the military was there.
It seems like the military was shooting the walkers and placing the bodies there.
It's right after Rick uses the matches to find his way out of the hospital using a stairwell.
Also, in a later episode it shows how Shane went to check on Rick.
The military can be seen in the hospital as I recall.
scifi.stackexchange.com/users/13382/charles sutton
There's no reason to guess, AMC explained this ages ago in
The Walking Dead: The Oath .
The Walking Dead: The Oath is a three-part web series based on the television series
The Walking Dead.
It aired in its entirety on October 1, 2013, on AMC's official website.
This series tells the origin of the "Don't Open, Dead Inside" paint on the cafeteria doors of the hospital Rick Grimes awakes in, post-apocalypse.
It follows Paul and Karina as they escape their zombie-overrun camp in search of a medical station.
The central theme of the series examines the will to persevere in the face of inevitable death.
scifi.stackexchange.com/users/89053/Michael Fontaine
Who wrote "Don't Open, Dead Inside" on the doors in the hospital that Rick sees after waking? Do they ever show it?
Who wrote "Don't Open, Dead Inside" on the doors inside the hospital?
scifi.stackexchange.com
<tv><the-walking-dead>
scifi.stackexchange.com/questions/31979
scifi.stackexchange.com/users/12658/elvis8664
The words were written there by the Walking Dead, presumably before the hospital was abandoned, possibly after a large number of patients had been moved into that one area (to better concentrate care) and one or more passed, raising as walkers, and began turning the others.   They must have left the hospital when it was abandoned by the living (or were killed there when it was overrun by the dead).   Though this was never explicitly shown in the comics, the understanding is it was the walking dead. However, in the video game, Merle is seen spray painting it.
Though this was never explicitly shown in the comics, the understanding is it was the walking dead. The on-set scenics painted it on. In the video game, Merle is seen spray painting it.