To-infinitives can be used in some places that you use gerunds, but not others. This one is fine. In both cases, going and to go, it is referring to the abstract idea of going. If it refers to a specific case that has actually happened, it doesn't work - like "going into space has made me ill". However, "going into space can make people ill" can have the gerund replaced by the to-infinitive and it will still be grammatically correct. It will seem stilted, though. English has plenty of cases where several forms are correct but only one actually gets used.
That's not the only guideline to when you can replace a gerund with a to-infinitive, mind you. I'm not sure anyone's really catalogued them all. Basically, sometimes the to-infinitive can go where a gerund would go without changing the meaning at all. Sometimes it will be valid but significantly change the meaning, though not often. Sometimes it will produce a completely invalid sentence. It doesn't matter if it's acting as a subject or an object of a verb, all three are possible. I'm not sure you can ever do it if the gerund is acting as the object of a preposition, mind you.