I understand how troops were needed to force the integration but what did Eisenhower gain from it? I mean it was before his re-election and it seems to me to be a good way to loose votes in 1950s America
Was it personal conviction? Was there something his administration gained from it?
Eisenhower's personal conviction was that blacks deserved equal rights but it was the president's job to uphold the law, not make it. He has been glorified and criticised because, despite being on the right side of history, he was an apolitical military man uncomfortable taking strong positions. A book aimed at non-specialists I found insightful is called Ike's Final Battle: The Road to Little Rock and the Challenge of Equality.
As to why he did it, this was one episode in a much larger saga. Governor Faubus of Arkansas called in the national guard in defiance of a court order, claiming "blood will run in the streets" if they admitted blacks. What followed set the stage for so-called massive resistance (closing schools) in Virginia and George Wallace standing in the school house door in Alabama. Eisenhower knew that. For Faubus, when he finally allowed the students to attend, it was a test case of his own. He could rile up whites with the prospect of total desegregation (which wasn't on the table yet), watch violence ensue, and say, "Told you so."
Eisenhower called his bluff. With the students' lives in danger, he decided to send in troops. NPR helps elaborate, shedding light on your latter question:
"What I remember at Ms. Bates' house is that you had all of this drama going on, but we were still teenagers. We were worried about how we were going to look getting into the jeep. Why couldn't we have two jeeps, instead of one. And Daisy said: 'Look, this is a very important moment. The fact that the president of the United States has sent the United States Army here to escort you into school means that this government is finally serious about school desegregation."
This was a moment of strength for the president, outside the racist voters of the south, who still voted Democratic anyway. Eisenhower showed desegregation was a battle he was willing to fight.
It is also important to point out that Faubus was directly ignoring a federal court order to integrate Little Rock's schools, and Eisenhower (being the Chief Executive of the federal government) had to show the supremacy of the federal government. To allow integration to be stalled in the face of a federal mandate because of the whims of a state governor would've damaged Eisenhower's credibility, especially after Eisenhower and Faubus met face to face about the crisis and Eisenhower thought it was resolved.
As a side note, last summer I went to Little Rock to work on a living memory project about the Little Rock Nine, where a group of educators (including myself), interviewed several people who experienced the painful integration of Little Rock's high schools, including a few of the Little Rock Nine themselves. It was an incredible experience.
I would like to add just a years prior Eisenhower allowed the governor of Texas, Allan shrivers, to prevent Mansfield high school from desegregating because he wanted Texas' electoral votes, though i doubt he really needed them. He also gave Texas rights to the tidelands over the federal government so it could suggest Eisenhower had some alliance with shrivers. I believe Orville Fabus was just part of Eisenhower being tough on the early attempts to defy desegregation.
While all of the other answers are very good, factual, and well-written, I believe they miss a larger context as to why Eisenhower sent troops: The Cold War. It is pretty common knowledge that Eisenhower could have actually cared less personally for the desegregation of schools, but did believe that once it was his responsibility to enforce the law, he would (a pretty soldiery mentality). However, much of why the Federal government and Eisenhower pushed the issue was because the Little Rock High School incident was an absolute field day for Soviet propaganda around the world. Here you have the supposed bastion of freedom in the world using State militia to keep some black children from going to school. The Soviets were showcasing this fact to every non-white nation that had to potential for communist sympathies as a huge reason for the US and capitalism actually being a farce. If the US didn't care about their own non-whites, why on earth would they care about other nations of non-whites except to exploit them. The US was taking a heavy beating on this and had to do something, and thus the use of federal troops to show the world "look, we take care of minorities and actually are as good as we say" could counter Soviet propaganda.
Much support from Democrats (and some Republicans, remember this is the period where a the Democrats were the racist party) for the 1963 Civil Rights Act was justified under foreign policy necessity, and not that it was the right thing to do.
EDIT: Grammar