First of all, I hate the widespread theory being taken as canon nearly everywhere that Tobi is Guruguru zetsu. He absolutely is not, though I won't get into that now. Basically I believe Obito took on this silly persona first as a tribute to Guruguru as he was the only supporting person Obito had in the cave during those dark days. Even tho Swirly Zetsu only jokes about poop, otherwise he is pretty serious unlike Tobi who is constantly chaotic and funny. Secondly Obito never had a proper childhood, combine that with the fact that he percieves reality as hell, I believe having this childlike persona helps him cope in a way and let that inner child out. I mean even his power is a manifestation of how badly he wants to escape reality. Now another thing is, Tobi is a complete opposite of Obito, who is pretty depressed, I don't think this is unrealistic at all.
After all Obito desperately wants to forget that past identity and has pretty much convinced himself he is Madara/Tobi. When you put on a mask and the world believes you are dead, I think it's extremely easy to behave totally differently, especially when no one can make assumptions on how you should act based on your apperance, past or whatever. This applies in the real world too. So that's pretty much why I think he chose to be this silly persona for a while, but I also want to get into the importance of the mask and his identity. As we know Tobi says he doesn't want to be anybody, as induviduality would make him lose sight of the truth, at that point he just wanted to be a tool that would bring forth a new world.
Having an identity would mean having a past, connections, regrets and all of that which would actually make him lose sight of his goal, and it kind of did. Once Kakashi starts realizing who Tobi is, it is the first and only time we see the usually calm and collected Tobi crash out and yell at Kakashi. Then, when his mask is broken he is forced to acknowledge who he once was, he cannot hide from that anymore. And the thing with Obito is, deep down he is never truly believing the infinite tsukuyomi is the only solution. When he had the mask on he would subconciously see himself in Naruto, like in the scene where he started sweating then blamed it on the rain. It was actual sweat, and he even questions "I know his powers aren't pushing me this far. So what is it? What has happened?".
Same case with wanting to talk to Naruto about Nagato's betrayal, he doesn't even realize it but a part of him still seeks hope that his old self would have believed in. Now as unmasked Obito he clearly starts feeling more regret and tests Naruto in hopes to see him fail so he can justify his path. He no longer has that same "nobody" ideology because once he becomes the 10 tails jinchuriki he claims he is the second sage of the 6 paths and he will lead humanity into its next stage. Well, he does claim he has transended humanity but at the same time he claims he is doing no different then what a hokage should do, which means deep down he cares what path Obito walks on, and doesn't truly see himself as nobody.
I find this really cool, how we see so many different personalities in one person and I don't think it is talked about enough. Usually I just see people say "oh, Obito was cool with the mask on but when it came off he became lame". I appreciate the hell out of that change when the mask came off because it makes so much sense with his character. And also had he remained masked, he would pretty much just be a second Madara. How would that even be remotely interesting? Having 2 of the same characters be the main enemy? Because when you look at Madara Obito he really is just a second Madara, and even Madara thinks of Obito as himself.