Gandhi was visibly depressed during his last days.
According to political psychologist Ashis Nandy:
Did Gandhi know what he was doing?“If Gandhi in his depression connived at it, he also perhaps felt- being the shrewd, practical idealist he was-that he had become somewhat of an anachronism in post-partition, independent India; and in violent death he might be more relevant to the living than he could be in life. As not a few have sensed, like Socrates and Christ before him. Gandhi knew how to use man’s sense of guilt creatively.”
He once said:
“I find no parallel in history for a body of converts and their descendants claiming to be a nation apart from the parent stock. If India was one nation before the advent of Islam, it must remain one in spite of the change of faith of a very large body of her children”
Gandhi in “Jinnah of Pakistan” by Stanley Wolpert, New Delhi 1985(1st edn 1984) page 232-3.
Ironically, the same line became a battle cry for BJP in the 90s.