It's hard to decide on its grammaticality because it is so awkward. It is not a sentence that would be written. On the other matter, 'only/merely/simply/just to' seem to me to be as they appear: adverbs introducing adverbial infinitive clauses.
New words, one handy idiom, and a 2-minute quiz — delivered to your inbox to keep your streak alive.
Mister Micawber because it is so awkward. It is not a sentence that would be written