Luffy got his powers by eating the Gomu Gomu no Mi. It's a Paramecia class devil fruit which transforms the user's entire body into rubber. He ate it when he was a kid and was visiting Shanks in the bar and he was hungry and it was lying there in an open chest.