When he dies, it actually incites the story. It is the problem of the story. The story's main character being Buttercup, her decision to never love again is affected by his supposed death in the beginning. Had Westley lived after she had just professed her love and he professed his, they may have ended up together early on in the book and the book would really have no where to go. This way, a problem is introduced, and the complications of Buttercup living with this loveless marriage develop the plot until we get to the point at which her problem of not loving can be resolved. Remember, in the beginning she decided she could only love Westley, and then she vowed to never love again. If he was (and he is) reintroduced in her life, she would fall for him all over again. This provides resolution to the problem.