I don't particularly like either sentence, but B is the better answer.
To fix A, you need to write "I wrote to my bank manager with the aim TO GET a loan. Since "to get" is an infinitive it can act as a noun, adjective, or adverb. In this case it is an adjective that modifies "aim".
"To getting" is not an infinitive. It cannot modify anything. "Getting" can be a noun, adjective, or adverb, but "to getting" cannot do these things. Since "getting a loan" acts as a noun, it makes sense to talk about "the aim OF getting a loan".
"View" works differently. You can have a view to a place: "from his room he has a view to France". If you think of "getting a loan" as a place, then a "view to getting a loan" makes sense.