This quote first appeared in a book called The Measure of a Man, published in 1959. The book was a publication of two sermons Martin Luther King gave at a conference sponsored by the United Church of Christ in 1958 at Purdue University. It later appeared in a sermon collection called Strength to Love (1963).
In the quote cited, King reiterated a familiar trope, also expressed in his "Letter from Birmingham Jail." He was distressed by white sympathizers who sat on the sidelines of the Civil Rights struggle and refused to fully commit to working for the cause of black equality.
It is easy, he says, to say the right words when all is well, but what matters is what you do when the rubber hits the road, so to speak (meaning, when it's put to the test). It basically means that if you are not there walking and working in solidarity with African Americans in times of controversy and danger then you do not really support the cause of social justice. In contrast, those who stand firm and put their well-being on the line are the people who bring about lasting change.