To be grammatically correct, should the following sentence end with an exclamation or question mark?

How nice it is !/?

Exclamation mark.

http://grammar.ccc.commnet.edu/grammar/marks/exclamation.htm

Thanks! Is the exclamation mark added even when considering only grammar and not emotions?

The reasons for using the exclamation mark are especially well stated in the linked webpage above.

You'll need to give me some examples for the rest of your question: "... even when considering only grammar..."

Well, suppose I say, "How nice it is?" Would that sentence be termed as grammatically incorrect?

Simply because the sentence begins with an interrogative word doesn't mean it's a question. A question mark there is an error.

Ask yourself ... is this truly a question? Or is it a remark about beautiful weather or a wonderful party? Or?

Grammatically, this is not a question. It's a remark that needs an exclamation mark at the end.

To determine whether the sentence should end with an exclamation or question mark, we need to consider the intended tone and meaning.

If the sentence is meant to express surprise, excitement, or enthusiasm, then it can be ended with an exclamation mark. For example: "How nice it is!" This punctuation emphasizes the strong emotion behind the statement.

On the other hand, if the sentence is intended to ask a question, seeking information or confirmation, then it should end with a question mark. For example: "How nice it is?" This punctuation indicates that the sentence is an inquiry or seeking clarification.

In this case, "How nice it is!" indicates a sense of surprise or admiration, so it would be more appropriate to end the sentence with an exclamation mark. However, if you intend it as a question to seek confirmation or further details, it should be "How nice it is?" with a question mark.