This question may have several answers based on opinion. Many such questions are eventually closed, but I think this may bee worth at least a discussion.
Until a few decade ago, the word sex was used to distinguish males from females, and had very little other connotations. It was used to describe either the trait (being a man or a woman) or the group (all men of all women). For example, Arthur Conan Doyle uses "the whole of her sex" to describe all women. Gender, on the other hand, was mostly a term used in grammar of many languages that have a distinction between male and female (and in some cases neutral) for all nouns, not just for people or animals (where it "makes sense"). In these languages every noun has a gender (not sex!). English has little notion of gender - the words he and she are used primarily according to the biological sex of a person, and the word it is used for almost every noun that does not refer to a person. So the terms "sex" and "gender" were related but not identical.
More recently the word "sex" got another meaning, that of sexual intercourse (nowadays this is probably the predominant use of this word). As such it acquired an offensive connotation, and some people feel uncomfortable using it. The word "gender" caught instead as a "clean language" term for the biological trait. This made "sex" and "gender" almost synonyms.
Even more recently, with the increased legitimacy and influence of the LGBT movement, there is an increased awareness that there are some people for whom the social or psychological identity does not match the biological and genetic trait of being a male or a female. Such people are identified (sometimes self-identified) as genderqueer, and their social identity is sometimes expressed by the linguistic gender they assume - for example, a biologically male person may prefer to be addressed as a "lady", "she", "sister", etc.
The awareness to the existence of genderqueers makes it important in some cases to inquire separately for a person's sex (biological trait) and for their gender (sociological identity). However, this is often a touchy point - many people object to the idea of genderqueer identity and would be angry of having separate questions.
I would assume that in a medical questionnaire this separation makes sense, especially in a society that is sensitive to LGBT rights. For example, a patient may have an external appearance of a female and be addressed as a woman, while having male organs; the medical team needs to be aware of this situation.